﻿using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Aribaccio.Office
{
    /// <summary>
    /// 
    /// </summary>
    public class OfficeFileModeTable
    {
        /// <summary>
        /// 文件模式数据字典集
        /// </summary>
        public static ConcurrentDictionary<OfficeFileMode, OfficeFileModeData> FileModeDatas { get; protected set; }
        /// <summary>
        /// 静态构造函数
        /// </summary>
        static OfficeFileModeTable()
        {
            FileModeDatas = new ConcurrentDictionary<OfficeFileMode, OfficeFileModeData>();
            FileModeDatas.TryAdd(OfficeFileMode.Csv, new OfficeFileModeData(OfficeFileMode.Csv, OfficeSheetMode.Single, ".csv", "CSV Data(*.csv)|*.csv"));
            FileModeDatas.TryAdd(OfficeFileMode.Excel, new OfficeFileModeData(OfficeFileMode.Excel, OfficeSheetMode.Single, ".xlsx", "Excel Data(*.xlsx)|*.xlsx"));
            //FileModeDatas.TryAdd(OfficeFileMode.CsvExcel, new OfficeFileModeData(OfficeFileMode.CsvExcel, OfficeSheetMode.Single, ".csv", "Data(*.xlsx, *.csv)|*.csv; *.xlsx"));
            FileModeDatas.TryAdd(OfficeFileMode.CsvExcel, new OfficeFileModeData(OfficeFileMode.CsvExcel, OfficeSheetMode.Single, ".csv", "All supported Data|*.csv;*.xlsx|CSV Data(*.csv)|*.csv|Excel Data(*.xlsx)|*.xlsx"));
        }
        /// <summary>
        /// 获取文件模式数据
        /// </summary>
        /// <param name="argFileMode">文件模式</param>
        /// <returns></returns>
        public static OfficeFileModeData GetToolFileModeData(OfficeFileMode argFileMode)
        {
            if (FileModeDatas == null || FileModeDatas.Count <= 0 || !FileModeDatas.ContainsKey(argFileMode)) { return null; }
            return FileModeDatas[argFileMode];
        }
        /// <summary>
        /// 获取文件模式数据
        /// </summary>
        /// <param name="argFileMode">文件模式</param>
        /// <returns></returns>
        public static string GetToolFileExtensionName(OfficeFileMode argFileMode)
        {
            if (FileModeDatas == null || FileModeDatas.Count <= 0 || !FileModeDatas.ContainsKey(argFileMode)) { return string.Empty; }
            OfficeFileModeData toolFileModeData = FileModeDatas[argFileMode];
            return toolFileModeData != null ? toolFileModeData.FileExtensionName : string.Empty;
        }
    }
}
